home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / PRRepMem.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  3.4 KB  |  159 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PRRepMem.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef PRSHATTR_H
  13. #include "PRShAttr.h"
  14. #endif
  15.  
  16. #ifndef FWFIXMEM_H
  17. #include "FWFixMem.h"
  18. #endif
  19.  
  20. #ifdef FW_BUILD_MAC
  21. #pragma segment FW_Graphics
  22. #endif
  23.  
  24. #ifdef FW_NATIVE_EXCEPTIONS
  25.  
  26. //========================================================================================
  27. // Memory management
  28. //========================================================================================
  29.  
  30. #define FW_SUBALLOCATE
  31.  
  32. //----------------------------------------------------------------------------------------
  33. // FW_CPrivInkRep
  34. //----------------------------------------------------------------------------------------
  35.  
  36. static FW_CFixedAllocator gInkAllocator(
  37.     sizeof(FW_CPrivInkRep)
  38. #ifdef FW_DEBUG
  39.     , "FW_CPrivInkRep"
  40. #endif
  41.     );
  42.  
  43. void* FW_CPrivInkRep::operator new(size_t size)
  44. {
  45.     FW_ASSERT(size == sizeof(FW_CPrivInkRep));
  46. #ifdef FW_SUBALLOCATE
  47.     return gInkAllocator.Allocate();
  48. #else
  49.     return ::operator new(size);
  50. #endif
  51. }
  52.  
  53. void FW_CPrivInkRep::operator delete(void* p)
  54. {
  55. #ifdef FW_SUBALLOCATE
  56.     gInkAllocator.Free(p);
  57. #else
  58.     ::operator delete(p);
  59. #endif
  60. }
  61.  
  62.  
  63. //----------------------------------------------------------------------------------------
  64. // FW_CPrivStyleRep
  65. //----------------------------------------------------------------------------------------
  66.  
  67. static FW_CFixedAllocator gStyleAllocator (
  68.     sizeof(FW_CPrivStyleRep)
  69. #ifdef FW_DEBUG
  70.     , "FW_CPrivStyleRep"
  71. #endif
  72.     );
  73.  
  74. void* FW_CPrivStyleRep::operator new(size_t size)
  75. {
  76.     FW_ASSERT(size == sizeof(FW_CPrivStyleRep));
  77. #ifdef FW_SUBALLOCATE
  78.     return gStyleAllocator.Allocate();
  79. #else
  80.     return ::operator new(size);
  81. #endif
  82. }
  83.  
  84. void FW_CPrivStyleRep::operator delete(void* p)
  85. {
  86. #ifdef FW_SUBALLOCATE
  87.     gStyleAllocator.Free(p);
  88. #else
  89.     ::operator delete(p);
  90. #endif
  91. }
  92.  
  93.  
  94. //----------------------------------------------------------------------------------------
  95. // FW_CPrivFontRep
  96. //----------------------------------------------------------------------------------------
  97.  
  98. static FW_CFixedAllocator gFontAllocator (
  99.      sizeof(FW_CPrivFontRep)
  100. #ifdef FW_DEBUG
  101.     , "FW_CPrivFontRep"
  102. #endif
  103.     );
  104.  
  105. void* FW_CPrivFontRep::operator new(size_t size)
  106. {
  107.     FW_ASSERT(size == sizeof(FW_CPrivFontRep));
  108. #ifdef FW_SUBALLOCATE
  109.     return gFontAllocator.Allocate();
  110. #else
  111.     return ::operator new(size);
  112. #endif
  113. }
  114.  
  115. void FW_CPrivFontRep::operator delete(void* p)
  116. {
  117. #ifdef FW_SUBALLOCATE
  118.     gFontAllocator.Free(p);
  119. #else
  120.     ::operator delete(p);
  121. #endif
  122. }
  123.  
  124.  
  125. //----------------------------------------------------------------------------------------
  126. // FW_CPrivPatternRep
  127. //----------------------------------------------------------------------------------------
  128.  
  129. #define MAX(a, b)    \
  130.     ((a) > (b)  ? (a) : (b))
  131.  
  132. static FW_CFixedAllocator gPatternAllocator (
  133.     MAX(sizeof(FW_CPrivBWPatternRep), sizeof(FW_CPrivColorPatternRep))
  134. #ifdef FW_DEBUG
  135.     , "FW_CPriv{BW|Color}PatternRep"
  136. #endif
  137.     );
  138.  
  139. void* FW_CPrivPatternRep::operator new(size_t size)
  140. {
  141. #ifdef FW_SUBALLOCATE
  142.     FW_UNUSED(size);
  143.     return gPatternAllocator.Allocate();
  144. #else
  145.     return ::operator new(size);
  146. #endif
  147. }
  148.  
  149. void FW_CPrivPatternRep::operator delete(void* p)
  150. {
  151. #ifdef FW_SUBALLOCATE
  152.     gPatternAllocator.Free(p);
  153. #else
  154.     ::operator delete(p);
  155. #endif
  156. }
  157.  
  158. #endif
  159.